package com.szrt.java.day20170109.demo06;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.junit.Test;

/**
 * HashMap 
 * @author zsrt
 *
 */

public class MapTest {

	@Test
	public void add(){
		//底层也是用了数组 + 栈
		//规则如果可以用接口/父类 申明一个变量  请一定用接口去申明
		Map<String,Integer> map = new HashMap<String,Integer>();
		
		
		map.put("胡斌", 24);
		map.put("陈皋", 23);
		map.put("刘浩", 24);
		map.put("黄后林", 33);
		
		Set<String> set = map.keySet();
		
		Iterator<String> it = set.iterator();
		
		while(it.hasNext()){
			String key = it.next();
			System.out.println(key);
		}
		
		System.out.println("=================================");
		
		Iterator<String> it2 = set.iterator();
		
		while(it2.hasNext()){
			String key = it2.next();
			System.out.println(key+"\t"+map.get(key));
		}
		
	}
	
}
